package com.atguigu.security;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

/**
 * @Description: 盐值加密
 * @Author: zhoufuzong
 * @Created: 2020-12-13 19:18:24
 * @Version: 1.1.0
 */

public class SercurityTest {
    public static void main(String[] args) {
        //1. 创建BcryptPasswordEncoder对象
        BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
        //2. 准备明文字符串
        String rawPassword="123123";
        String encode = passwordEncoder.encode(rawPassword);
        System.out.println(encode);

    }

}

class EncodeTest{
    public static void main(String[] args) {
        //1.准备明文字符串
        String rawPassword ="123123";
        //2.准备密文字符串
        String encodePassword = "$2a$10$Gl5yFXIVjkyCzJRtdRmbnuN5I9ufA04HoBworeJJAlwfkeXHdNM/6";
        // 3. 创建
        BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
        boolean matches = passwordEncoder.matches(rawPassword, encodePassword);
        System.out.println(matches?"一致":"不一致");
    }
}
